﻿@using PagedList
@model PagedList.IPagedList<ShenLanCMS.Models.Post>
@{
    ViewBag.Title = "文章管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<fieldset>
    <legend>文章管理 | @Html.ActionLink("添加", "add")</legend>
    <br />
    <table>
        <tr>
            <th>
                作者
            </th>
            <th>
                标题
            </th>
            <th>
                分类
            </th>
            <th>
                时间
            </th>
            <th>
                顶
            </th>
            <th>
                踩
            </th>
            <th>
                点击
            </th>
            <th>
                权重
            </th>
            <th>
                状态
            </th>
            <th>
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @item.GetUser().UserName
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Title)
                </td>
                <td>
                    @item.GetPostType().TypeName
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.PubTime)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DigGood)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DigBad)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Click)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Weight)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Status)
                </td>
                <td>
                    @Html.ActionLink("编辑", "Edit", new { id = item.PostID }) | <a href="view/@item.PostID" target="_blank">
                        查看</a> | <a href="javascript:delpost('@item.PostID')">删除</a>
                </td>
            </tr>
        }
    </table>
    <div style="width: auto; height: 30px; margin-top: 10px; text-align: center;">
        @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
        / @Model.PageCount
        &nbsp;
        @if (Model.HasPreviousPage)
        {
            @Html.ActionLink("首页", ViewData["actionName"].ToString(), new { page = 1, currentFilter = ViewBag.CurrentFilter })
            @Html.Raw("&nbsp;");
            @Html.ActionLink("< 上一页", ViewData["actionName"].ToString(), new { page = Model.PageNumber - 1, currentFilter = ViewBag.CurrentFilter })
        }
        else
        {
            @Html.Raw("首页&nbsp;&nbsp;上一页")
        }
        &nbsp;
        @if (Model.HasNextPage)
        {
            @Html.ActionLink("下一页 >", ViewData["actionName"].ToString(), new { page = Model.PageNumber + 1, currentFilter = ViewBag.CurrentFilter })
            @Html.Raw("&nbsp;");
            @Html.ActionLink("尾页", ViewData["actionName"].ToString(), new { page = Model.PageCount, currentFilter = ViewBag.CurrentFilter })
        }
        else
        {
            @Html.Raw("下一页&nbsp;&nbsp;尾页")
        }
    </div>
</fieldset>
<script type="text/javascript">
    function delpost(obj) {
        if (confirm("确定要放入回收站吗?")) {
            $.post("/post/delete/" + obj, function (data) {
                alert(data);
                if (data == "操作成功")
                    window.location.reload();
            }
        );
        }
    }
</script>
<script src="../../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
